/**
    Copyright (c) 2009 yakiimo02
    Distributed under the New BSD License.
    See included license.txt or http://www.yakiimo3d.com/NewBSDLicense.txt
**/

#pragma once

#include "BitonicSortCPU.h"

/**
    @brief  CPU implementation of Bitonic Sort that uses loop iteration.
            Based on code from http://www.tools-of-computing.com/tc/CS/Sorts/bitonic_sort.htm
            which I learned about from http://developer.download.nvidia.com/compute/cuda/sdk/website/samples.html
            the Nvidia Cuda SDK Bitonic Sort sample.
            Bitonic sort modified for per frame step execution. 
    @author yakiimo02
    @date    09/11/28
*/
class BitonicSortDemo : public BitonicSortCPU
{
public:
    virtual void SortUp() {};
    virtual void SortDown() {};

    virtual void SortBegin( bool bSortUp, int nElemPerFrame );
    virtual void Update();

protected:
    void Sort( int nCount );

protected:
    //        bitonic sort loop variables
    int        m_nMergeSize;                    
    int        m_nMergeSubSize;                
    int        m_nElem;                        
    //
    int        m_nElemPerFrame;                // number of elements to sort per frame
};
